from dataclasses import dataclass
from typing import Optional


@dataclass
class DatabaseConfig:
    host: str = "localhost"
    port: int = 5432
    database: str = "postgres"
    user: str = "admin"
    password: Optional[str] = "pg123456"

    @property
    def connection_string(self) -> str:
        auth = f"{self.user}:{self.password}" if self.password else self.user
        return f"postgresql://{auth}@{self.host}:{self.port}/{self.database}"
